<?php
	/**
	* Video save
	* @author trungdt
	* @since Oct 26, 2011
	* 
	* Change logs
	* 
	*/

	if (!defined('EXPONENT')) exit('');

	$video = null;
	if (isset($_POST['id'])) {
		$video = $db->selectObject('videomodule_video','id='.intval($_POST['id']));
		if ($video) {
			$loc = unserialize($video->location_data);
		}
	} 

	if (exponent_permissions_check(array('administrate','configure', "edit", "create"),$loc)){
		$video = videomodule_video::video_update($_POST,$video);
		$video->location_data = serialize($loc);

		if (isset($video->id)) {
			$db->updateObject($video,'videomodule_video');
		} else {
			$db->insertObject($video,'videomodule_video');
		}
		exponent_flow_redirect();
	} else {
		echo exponent_http_error(404);
	}

?>
